﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace AncientEmpires_025_132
{
    public class MyMouse : VisibleGameEntity
    {
        private MyMouseState gameMouse;
        public MyMouseState GameMouse
        {
            get { return gameMouse; }
            set { 
                    gameMouse = value;
                    switch (gameMouse)
                    {
                        case MyMouseState.Normal:
                            ListSprites[ISprite].ITexture = 0;
                            break;
                        case MyMouseState.ChooseCharacter:
                            ListSprites[ISprite].ITexture = 1;
                            break;
                        case MyMouseState.ChooseBuilding:
                            ListSprites[ISprite].ITexture = 2;
                            break;
                        case MyMouseState.Hit:
                            ListSprites[ISprite].ITexture = 3;
                            break;
                        case MyMouseState.Run:
                            ListSprites[ISprite].ITexture = 4;
                            break;
                    }
                }
        }

        public MyMouse(ContentManager content, string[] strtexture, Vector2 size)
        {
            ListSprites = new List<Sprite2D>();
            MouseState ms = Mouse.GetState();
            Texture2D[] texture = new Texture2D[strtexture.Length];
            for (int i = 0; i < strtexture.Length; i++)
            {
                texture[i] = content.Load<Texture2D>(strtexture[i]);
            }
            Sprite2D tempsprite = new Sprite2D(texture, new Vector2(ms.X, ms.Y));
            tempsprite.Size = size;
            ListSprites.Add(tempsprite);
            ISprite = 0;
        }
        public override void Update(GameTime gameTime)
        {
            MouseState ms = Mouse.GetState();
            ListSprites[ISprite].Position = new Vector2(ms.X, ms.Y);
            //base.Update(gameTime);
        }
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            int i = ISprite;
            Rectangle rect = new Rectangle();
            if (ListSprites[i].Size.X == 0 && ListSprites[i].Size.Y == 0)
            {
                ListSprites[i].Size = new Vector2(40, 40);
            }
            rect = new Rectangle((int)ListSprites[i].Position.X, (int)ListSprites[i].Position.Y, (int)ListSprites[i].Size.X, (int)ListSprites[i].Size.Y);
            spriteBatch.Draw(ListSprites[i].Textures[ListSprites[i].ITexture], rect, Color.White);

        }
    }
}
